package com.github.prontera.controller;

import io.swagger.annotations.ApiOperation;

import java.time.OffsetDateTime;
import java.util.HashMap;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.github.prontera.ApiVersion;
import com.github.prontera.RequestLogging;
import com.github.prontera.domain.ClientRent;
import com.github.prontera.domain.Tags;
import com.github.prontera.model.response.ObjectDataResponse;
import com.github.prontera.service.ClientRentService;
import com.github.prontera.util.Page;

/**
 * 技能标签
 * @author Alex
 */
@RestController
@RequestMapping(value = ApiVersion.MANAGE_V1_PREFIX + "/rent", produces = { MediaType.APPLICATION_JSON_UTF8_VALUE }, consumes = { MediaType.APPLICATION_JSON_UTF8_VALUE })
public class ClientRentController {

	@Autowired
	private ClientRentService clientRentService;

	@ApiOperation(value = "查询技能内容", notes = "查询技能内容")
	@RequestMapping(value = "findRentList", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Page<HashMap<String, Object>>> findRentList(@RequestBody ClientRent clientRent) {
		Page<HashMap<String, Object>>  page = clientRentService.pageList(clientRent);
		return new ObjectDataResponse<Page<HashMap<String, Object>>>(page);
	}

	@ApiOperation(value = "修改技能审核状态", notes = "修改技能审核状态")
	@RequestMapping(value = "updateRent", method = RequestMethod.POST)
	@ResponseBody
	public ObjectDataResponse<Integer> updateRent(@RequestBody ClientRent rent) {
		if(rent!=null){
			rent.setUpdateTime(OffsetDateTime.now());
		}
		Integer res = clientRentService.update(rent);
		return new ObjectDataResponse<Integer>(res);
	}
}
